package cn.oslanka.mls.sql;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import cn.oslanka.mls.BaseApp;
import cn.oslanka.mls.config.AppConfig;


/**
 * Created by T400 on 15-6-25.
 */
public class MySqlitehelper extends SQLiteOpenHelper {
    public MySqlitehelper() {
        super(BaseApp.getApplication(), AppConfig.SQLDATANAME, null, AppConfig.SQLDATAVERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table user(_id integer primary key,uid,name)");
        db.execSQL("create table savecount(_id integer primary key,beanname,count)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (newVersion>oldVersion){
            db.execSQL("drop table if exists user");
            db.execSQL("drop table if exists savecount");
        }
        onCreate(db);
    }
}
